#ifndef _CDECORATION_H_
#define _CDECORATION_H_

#include "auto.h"

#include <buola/gui/x11/cx11window.h>
#include <buola/utility/uevent.h>
#include <buola/gl/ctexture.h>

namespace buola { namespace bwm {

class CDecoration : public UUncopiable, public UTrackable
{
public:
    CDecoration(CClient *pClient);
    virtual ~CDecoration();

    void Create(const CPoint_i &pPos,const CSize_i &pSize,const CPoint_i &pXPos);

    Window CreateDecoWindow(const CPoint_d&,const CSize_d&);

    virtual void InitInternal()     {}
    virtual void InitStatic()       {}

    virtual CRect_i GetTotalExtent()=0;
    virtual CRect_i GetFrameExtent()=0;

    virtual void Paint(const CRegion &pRegion,int pDesktop)=0;
    virtual void PaintBaseLine()=0;
    
    virtual void Refresh();

//////////////// event handlers /////////////////
    virtual void OnGeometryChanged(bool pResize,const CPoint_i &pPos,
                                const CSize_i &pSize,const CPoint_i &pXPos);
    virtual void OnShapeChanged();
    virtual void OnOpacityChanged();
    virtual void OnClientMapped();
    virtual void OnClientUnmapped();
    virtual void OnDecorationExpose(XExposeEvent*);

    virtual void OnButtonDown(const CPoint_d&,gui::EMouseButton,int) {}
    virtual void OnButtonUp(const CPoint_d&,gui::EMouseButton,int) {}
    virtual void OnMouseMove(const CPoint_d&) {}
    virtual void OnMouseOut() {}

public:
    UEvent<void()> eDamage;
    
protected:
    CClient *mClient;

    CPoint_i mClientXPos;
    CSize_i mClientSize;

public:
    std::vector<Window> mDecoWindows;

public:
    friend class CRootWindow;
    friend class CEventManager;
};

/*namespace bwm*/ } /*namespace buola*/ }

#endif
